package renpyas3.view.instructions
{
	import renpyas3.model.RenpyPlayerModel;
	import renpyas3.view.RenpyPlayer;
	
	/**
	 * finishes a screen, returns to previous screen or finishes execution
	 */
	public class ViewInstruction_return extends ViewInstruction
	{
		public static const NAME:String = "return";
		
		public function ViewInstruction_return() 
		{
			
		}
		
		/**
		 * execute a the code for this command, altering RenpyPlayerViewState
		 * @param	view  is the whole set of view state variables and operations that make up the VIEW
		 * @param	model the data needed to play a renpy novel
		 * @param	params   extra data for some instructions
		 */
		override public function execute(view:RenpyPlayer, model:RenpyPlayerModel, params:Object=null):void
		{
			if (model.currentLabelBlock.name == "splashscreen")
			{
				model.jumpToNextLabelBlockInSequence();
			}
			else
			{
				model.returnToPreviousScreen();
			}
			//all done in this command
			view.instructionsProcessor.instructionFinished();		
		}			
	}
}